package workspace.teaweb.CRM.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import workspace.teaweb.CRM.mappers.CRMMapper;
import workspace.teaweb.CRM.pojo.dto.CrmQuery;
import workspace.teaweb.CRM.pojo.entity.CRM;
import workspace.teaweb.CRM.pojo.vo.CRMVO;
import workspace.teaweb.CRM.service.CRMService;
import workspace.teaweb.base.response.JsonResult;

import java.util.List;

@Slf4j
@Service
public class CRMServiceImpl implements CRMService {

    @Autowired
    private CRMMapper crmMapper;

    // 增加CRM记录
    @Override
    public void addCRM(CRM crm) {
        crmMapper.insert(crm);
    }


    // 更新CRM记录
    @Override
    public void updateCRM(CRM crm) {
        crmMapper.update(crm);
    }


    // 查询所有CRM记录
    @Override
    public List<CRM> getAllCRM() {
        return crmMapper.findAll();
    }


    // 根据ID获取CRM记录
    @Override
    public CRM getCRMById(int id) {
        return crmMapper.findById(id);
    }

    //根据姓名查询员工
    @Override
    public List<CRM> getName(String name) {
        return null;
    }


    // 根据职位查询员工
    @Override
    public List<CRM> getlevelPosition(String position) {
        return null;
    }


    // 记录加班小时
    @Override
    public void recordOverHour(int employeeId, int hours) {

    }

    // 记录请假小时
    @Override
    public void recordLeaveHour(int employeeId, int hours) {

    }

    // 注册用户
    @Override
    public void register(CRM user) {

    }






    // 增加CRM记录
    @Override
    public void deleteCRM(int id) {

    }


    // 注册用户
    public class LoginRequest {
        private String username;
        private String password;

        // Getter 和 Setter
        public String getUsername() {
            return username;
        }

        public void setUsername(String username) {
            this.username = username;
        }

        public String getPassword() {
            return password;
        }

        public void setPassword(String password) {
            this.password = password;
        }
    }


    // 登录验证
    public class Crm {
        private String name;
        private String password;
        private String fullName; // 其他字段可以根据需求添加

        // Getter 和 Setter
        public String getname() {
            return name;
        }

        public void setname(String name) {
            this.name = name;
        }

        public String getPassword() {
            return password;
        }

        public void setPassword(String password) {
            this.password = password;
        }

        public String getName() {
            return fullName;
        }

        public void setName(String fullName) {
            this.fullName = fullName;
        }
    }

    //获取员工的信息
    @Override
    public CRM getEmployeeInfo(int id) {
        return null;
    }


    //员工查询  业务层
    @Override
    public List<CRMVO> selectCRM(CrmQuery crmQuery) {
        List<CRMVO> list = crmMapper.selectCRM(crmQuery);
        return list;
    }
}
